home *** CD-ROM | disk | FTP | other *** search
- /*
- File: OutboundScripting.c
-
- Copyright (c) 1990, Thomas Knoll.
- Copyright (c) 1991-6, Adobe Systems Incorporated.
- All rights reserved.
-
- C source file for scripting functions for Outbound export example.
- */
-
- #include "Outbound.h"
-
- /*****************************************************************************/
- /* Checks the parameters against scripting-returned parameters, if any, and
- updates our parameters to match ones given to us by the scripting system. */
-
- Boolean ReadScriptParams (GPtr globals)
- {
- PIReadDescriptor token = NULL;
- DescriptorKeyID key = NULLID;
- DescriptorTypeID type = NULLID;
- DescriptorKeyIDArray array = { keyIn, NULLID };
- int32 flags = 0;
- OSErr stickyError = noErr;
- Boolean returnValue = true;
-
- if (DescriptorAvailable())
- {
- token = OpenReader(array);
- if (token)
- {
- while (PIGetKey(token, &key, &type, &flags))
- {
- switch (key)
- {
- case keyIn:
- PIGetAlias(token, &(Handle)gAliasHandle);
- break;
- // ignore all other cases and classes
- }
- }
-
- stickyError = CloseReader(&token); // we're done, dispose.
-
- if (stickyError)
- {
- if (stickyError == errMissingParameter)
- ;
- /* (descriptorKeyIDArray != NULL) Missing a parameter.
- Walk IDarray for which one. */
- else
- gResult = stickyError; // real error occurred
- }
- }
- gQueryForParameters = returnValue = PlayDialog();
- /* return TRUE if want to show our Dialog */
- }
- return returnValue;
- }
-
- /*****************************************************************************/
- /* Writes our parameters to the scripting system. */
-
- OSErr WriteScriptParams (GPtr globals)
- {
- PIWriteDescriptor token = nil;
- OSErr gotErr = noErr;
-
- if (DescriptorAvailable())
- {
- token = OpenWriter();
- if (token)
- {
- PIPutAlias(token, keyIn, (Handle)gAliasHandle);
- gotErr = CloseWriter(&token); // closes and sets to dialogOptional
-
- /* dispose the handle we created. Since it's different on
- Mac and Windows, we'll put the destroy routine in UIMac or UIWin. */
-
- DestroyAliasHandle (globals);
- /* done. Now pass handle on to Photoshop */
- }
- }
- return gotErr;
- }
-
- /*****************************************************************************/
-